package com.isunland.managesystem.ui;

import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;
import com.isunland.managesystem.entity.AttendanceParams;
import com.isunland.managesystem.entity.CurrentUser;
import com.isunland.managesystem.ui.NewAttendanceDetailFragment.Callbacks;
import java.util.Date;

public class AttendancePagerActivity extends BasePagerActivity
    implements Callbacks, AttendanceListFragment.Callbacks {
  @SuppressWarnings("unused") private static final String TAG = "AttendancePagerActivity";
  //	private AttendanceDetailFragment mAttendanceDetailFragment;
  private AttendanceListFragment mAttendanceListFragment;
  private NewAttendanceDetailFragment mAttendanceDetailFragment;

  //	private int[] mTitleId = { R.string.attendanceDetail,
  //			R.string.attendanceRecord, };
  private int[] mTitleId = {
      R.string.sign_everyday, R.string.sign_list
  };

  @Override public void onRefresh() {
    setNavigateTo(1);
    mAttendanceListFragment.refresh();
  }

  @Override protected android.support.v4.app.Fragment createFragmentOne() {
    //		mAttendanceDetailFragment=new AttendanceDetailFragment();
    mAttendanceDetailFragment = new NewAttendanceDetailFragment();
    return mAttendanceDetailFragment;
  }

  @Override protected android.support.v4.app.Fragment createFragmentTwo() {
    AttendanceParams params = new AttendanceParams();
    params.setNames(CurrentUser.newInstance(this).getJobNumber());
    params.setTypeFrom(AttendanceListFragment.TYPE_USER);
    mAttendanceListFragment = (AttendanceListFragment) AttendanceListFragment.newInstance(params,
        new AttendanceListFragment());
    return mAttendanceListFragment;
  }

  @Override protected int[] createTitle() {

    return mTitleId;
  }

  @Override public void onSignInfoUpdate(Date signIn, Date singOut) {
    mAttendanceDetailFragment.updateSignInfo(signIn, singOut);
  }
}
